<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Input;
use Mews\Purifier\Facades\Purifier;

/**
 *
 * @author Harris
 * @since 3.1
 * @see 防止JS注入
 */

class AgainstJSInjection {

    public function handle($request, Closure $next) {
        $input = Input::all();
        foreach ($input as $key => $value) {
            $input['key'] = Purifier::clean($value);
        }
        Input::merge($input);

        return $next($request);
    }
}